package com.ma.user;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.ma.R;
import com.ma.home.HomeActivity;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import base.BaseActivity;
import bean.LoginBean;
import bean.SycnRequstBean;
import httpUtil.Api;
import httpUtil.Http;
import utils.ConstantUtil;
import utils.JsonUtil;
import utils.SharedPrefUtil;

public class LoginActivity extends BaseActivity {

    private LoginBean bean;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        requestWindowFeature(Window.FEATURE_NO_TITLE);//remove title bar  即隐藏标题栏
        getSupportActionBar().hide();// 隐藏ActionBar
        setContentView(R.layout.activity_login);
    }

    public void login(View view) {
        showProgressDialog();
        Map<String,Object> map =new HashMap<>();
        map.put("DLZH","gg00001");
        map.put("DLMM","123456");
        Http.post(Api.APPLogin,map)
                .subscribe(res -> {
                    logJson(res);
                    if(res.getCode()==200){
                        bean=  JsonUtil.getObject(res.getContent().toString(), LoginBean.class);
                        SharedPrefUtil.getInstance().putInt(ConstantUtil.XMBS  ,bean.getBMJGData().get(0).getXMBS());
                        closeProgressDialog();
                        Intent intent = new Intent(this,HomeActivity.class);
                        intent.putExtra(ConstantUtil.DATA1,bean);
                        startActivity(intent);

                    }
                },throwable -> {
                    closeProgressDialog();
                    logJson(throwable);
                        }
                );

    }

    public void settings(View view) {
        ChoseCompanyDialog dialog = new ChoseCompanyDialog(this);
        dialog.show();

    }



}
